package v1

import (
	"github.com/gin-gonic/gin"
	"guns-go/model/request"
	"guns-go/model/response"
	"guns-go/service"
)

// @Tags Mail
// @Summary 发送普通邮件
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.SendMailParam true "请求参数"
// @Success 200 {string} string "{"success":true,"data":{},"message":"请求成功","code":200}"
// @Router /email/sendEmail [post]
func SendMail(c *gin.Context) {

	var M request.SendMailParam
	_ = c.ShouldBindJSON(&M)

	err := service.SendMail(&M)

	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	response.Ok(c)
}

// @Tags Mail
// @Summary 发送html邮件
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.SendMailParam true "请求参数"
// @Success 200 {string} string "{"success":true,"data":{},"message":"请求成功","code":200}"
// @Router /email/sendEmailHtml [post]
func SendHtmlMail(c *gin.Context) {

	var M request.SendMailParam
	_ = c.ShouldBindJSON(&M)

	err := service.SendHtmlMail(&M)

	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	response.Ok(c)
}
